from pathlib import Path
import os
from send2trash import send2trash
from traceback import print_exc


from gitignore_parser import parse_gitignore


HERE_PATH = Path(os.path.dirname(__file__))

matches = parse_gitignore(HERE_PATH / '.gitignore', HERE_PATH)

files_to_be_deleted = []

for f in HERE_PATH.iterdir():
    if(matches(f)):
        files_to_be_deleted.append(f)

print('== FILES TO BE DELETED ==')
file_name_list = [t.name for t in files_to_be_deleted]
print('\n'.join(file_name_list))

print('->? Continue?')
print()

os.system('pause')

for f in files_to_be_deleted:
    try:
        send2trash(f)
    except e:
        print_exc()
        os.system('pause')
